home *** CD-ROM | disk | FTP | other *** search
/ Stone Design / Stone Design.iso / Stone_Friends / 3D_Rendering / Musgrave_Shaders / Source / starfield.sl < prev    next >
Encoding:
Text File  |  1994-12-08  |  1.1 KB  |  42 lines

  1. /*
  2.  * starfield.sl -- Surface shader for a star field.
  3.  *
  4.  * DESCRIPTION:
  5.  *   Makes a star field.  Best when used as a surface shader for the inside
  6.  *   of a large sphere.
  7.  * 
  8.  * PARAMETERS:
  9.  *   frequency          frequency of the stars
  10.  *   intensity          how bright are the stars?
  11.  *   pswidth            how wide is the point spread function?  i.e. larger
  12.  *                      values make "wider" stars, but the look less round.
  13.  *
  14.  * AUTHOR: written by Larry Gritz, 1992
  15.  *
  16.  * HISTORY:
  17.  *      28 Dec 1992 -- written by lg for the "Timbre Trees" video (saucer)
  18.  *      12 Jan 1994 -- recoded by lg in correct shading language.
  19.  *
  20.  * last modified  12 Jan 1994 by Larry Gritz
  21.  */
  22.  
  23.  
  24.  
  25. surface
  26. starfield ( float intensity = 1;
  27.         float frequency = 1;
  28.         float pswidth = 0.01)
  29. {
  30.   point PP;
  31.   float val;
  32.  
  33.   /* Shade in shader space */
  34.   PP = frequency * transform ("shader", P);
  35.  
  36.   /* Use a noise value, but only keep the "tips" of the blotches */
  37.   val = smoothstep (1-pswidth, 1, noise(PP));
  38.  
  39.   /* scale it by the intensity and sharpen it by squaring */
  40.   Ci = intensity * val*val;
  41. }
  42.